package cn.wolfcode.crm.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import cn.wolfcode.crm.domain.SystemDictionaryItem;
import cn.wolfcode.crm.mapper.SystemDictionaryItemMapper;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.ISystemDictionaryItemService;

@Service
public class SystemDictionaryItemServiceImpl implements ISystemDictionaryItemService {

	@Autowired
	private SystemDictionaryItemMapper systemdictionaryItemMapper;

	@Override
	public void saveOrUpdate(SystemDictionaryItem entity) {
		if (entity.getId() == null) {
			systemdictionaryItemMapper.insert(entity);
		} else {
			systemdictionaryItemMapper.update(entity);
		}

	}

	@Override
	public SystemDictionaryItem get(Long id) {
		return systemdictionaryItemMapper.selectById(id);
	}

	@Override
	public PageInfo<SystemDictionaryItem> list(QueryObject qo) {
		PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
		List<SystemDictionaryItem> list = systemdictionaryItemMapper.selectAll(qo);
		return new PageInfo<>(list);
	}
	
	@Override
	public List<SystemDictionaryItem> listNotPage(QueryObject qo) {
		List<SystemDictionaryItem> list = systemdictionaryItemMapper.selectAll(qo);
		return list;
	}
	
	@Override
	public void delete(Long id) {
		systemdictionaryItemMapper.delete(id);
	}

}
